<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="com.webapp.model.Employee, com.webapp.model.ManagerModel, java.util.List" %>
<% 
	List myEmployees =  (List)session.getAttribute("Employees");
	System.out.print(myEmployees);
	if(myEmployees == null)
		response.sendRedirect("Error.jsp");
%>
<!-- include moo talk header file -->
<%@ include file="MooTalkHeader.jsp" %>

		<div id="site_content_text">
			<% 
				String x = request.getParameter("employee"); 
				if(x != null) {
					
					if(x.equals("added")) {
						%>
							<p style="color:red;">
								Employee Added!
							</p>
						<%
					}
					
					if(x.equals("deleted")) {
						%>
							<p style="color:red;">
								Employee was removed!
							</p>
						<%
					}
					
					if(x.equals("edited")) {
						%>
							<p style="color:red;">
								The employee was successfully edited!
							</p>
						<%
					}
					
					if(x.equals("notexists")) {
						%>
							<p style="color:red;">
								The employee does not exist!
							</p>
						<%
					}
					
					if(x.equals("nothing")) {
						%>
							<p style="color:red;">
								There are no employees to delete!
							</p>
						<%
					}
					
					if(x.equals("no employees")) {
						%>
							<p style="color:red;">
								Sorry there are no employees!
							</p>
						<%
					}
				} 
			%>
			
			<form id="createEmployee" name="createEmployee" action="CreateEmployee.jsp?employee=newemployee" method="post">
					<input class="btn"type="submit" value="Create Employee"/>
			</form>
			<form id="viewTransactions" name="viewTransactions" action="DeleteEmployee.do" method="post">
					<label><strong>Enter employee's SSN to delete:</strong></label><br/>
					<input type="text" name="DeleteEmployee"/><br/>
					<input class="btn"type="submit" value="Delete Employee" />
			</form>
			<form id="viewTransactions" name="viewTransactions" action="EditEmployee.do" method="post">
					<label><strong>Enter employee's SSN to Edit:</strong></label><br/>
					<input type="text" name="EditEmployee"/><br/>
					<input class="btn"type="submit" value="Edit Employee" />
			</form>
			
			<% if (user.getType().toLowerCase().equals("manager")) { %>
				<h2>All Employees</h2>
				<table border="1"> <tr>
										<td><font size="2" face="arial" color="black">SSN</font></td>
										<td><font size="2" face="arial" color="black">Last Name</font></td>
										<td><font size="2" face="arial" color="black">First Name</font></td>
										<td><font size="2" face="arial" color="black">Email</font></td>
										<td><font size="2" face="arial" color="black">Hourly Wage</font></td>
										<td><font size="2" face="arial" color="black">Start Date</font></td>
										<td><font size="2" face="arial" color="black">Manager</font></td>
										<td><font size="2" face="arial" color="black">Employee ID</font></td>
										<td><font size="2" face="arial" color="black">Address</font></td>
										<td><font size="2" face="arial" color="black">City</font></td>
										<td><font size="2" face="arial" color="black">Zip Code</font></td>
				</tr>
				<% if (myEmployees.size() == 0) { %>
					<p>There are no advertisements!</p>
					</table>
				<% } else {
					for(int i = 0; i < myEmployees.size(); i++) { 
						Employee theEmployee = (Employee)myEmployees.get(i);
						if(i%2 == 0) { %>
						<%
						} else { %>
						<% }%>
							<tr>
									<td><font size="2" face="arial" color="black"> <%=theEmployee.getSSN() %> </font></td>
									<td><font size="2" face="arial" color="black"> <%=theEmployee.getLastName() %> </font></td>
									<td><font size="2" face="arial" color="black"> <%=theEmployee.getFirstName() %> </font></td>
									<td><font size="2" face="arial" color="black"> <%=theEmployee.getEmail() %> </font></td>
									<td><font size="2" face="arial" color="black"> <%=theEmployee.getHourlyWage() %> </font></td>
									<td><font size="2" face="arial" color="black"> <%=theEmployee.getStartDate() %> </font></td>
									<td><font size="2" face="arial" color="black"> <%=theEmployee.getManager() %> </font></td>
									<td><font size="2" face="arial" color="black"> <%=theEmployee.getEmployeeId() %> </font></td>
									<td><font size="2" face="arial" color="black"> <%=theEmployee.getAddress() %> </font></td>
									<td><font size="2" face="arial" color="black"> <%=theEmployee.getCity() %> </font></td>
									<td><font size="2" face="arial" color="black"> <%=theEmployee.getZip() %> </font></td>
							</tr>
				<% }
				} %> </table>
			<% }%>
			<br/>
			<hr/>
			<br/>
		</div>
		
<!--  include moo talk footer file -->
<%@ include file="MooTalkFooter.jsp" %>
